#include <iostream>
#include <iterator>
#include <fstream>
#include <algorithm>
#include <list>
#include <deque>
#include <set>

using namespace std;

// ostream_iterator is a good printer to any stream.

template <typename Container>
void print(Container &container, const char *seperator = "\n", ostream &os = cout)
{
    ostream_iterator<typename Container::value_type> oit(os, seperator);
    copy(container.begin(), container.end(), oit);
}

void _good_cout()
{
    std::list<int> lst = {1, 2, 3, 4, 5};
    std::vector<int> vec = {10, 20, 30, 40, 50};
    std::deque<int> deq = {100, 200, 300, 400, 500};
    std::set<int> st = {1000, 2000, 3000, 4000, 5000};

    print(lst, ", ");  // 使用逗号作为分隔符
    print(vec, " - "); // 使用短横线作为分隔符
    print(deq, " | "); // 使用竖线作为分隔符
    print(deq);        // 使用竖线作为分隔符
    print(st, "\n");   // 每个元素换行
}

int main(int argc, char *const argv[])
{
    _good_cout();
    if (argc != 4)
    {
        cout << "Usage: " << argv[0] << " <input file> <output file> <output file2>" << endl;
        return -1;
    }
    ifstream in(argv[1]);
    if (!in)
    {
        cerr << "Error: " << argv[1] << " could not be opened." << endl;
        return -1;
    }
    ofstream out(argv[2]);
    if (!out)
    {
        cerr << "Error: " << argv[2] << " could not be opened." << endl;
        return -1;
    }
    ofstream out2(argv[3]);
    if (!out2)
    {
        cerr << "Error: " << argv[3] << " could not be opened." << endl;
        return -1;
    }

    istream_iterator<int> in_iter(in), eof;
    ostream_iterator<int> out_iter(out, " ");
    ostream_iterator<int> out_iter2(out2, "\n");
    while (in_iter != eof)
    {
        if (*in_iter & 1)
        {
            *out_iter++ = *in_iter++;
        }
        else
        {
            *out_iter2++ = *in_iter++;
        }
    }
    return 0;
}